<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>Save As</title>
<script type="text/javascript">
/* (c) 2007 VK [schools_ring@yahoo.com]
* All copyrights are given to the world.
*/
function saveAs(doc, path) {
  if (('ActiveXObject' in window) &&
      (typeof document.execCommand == 'object')) {
    try {
      doc.execCommand('SaveAs', false, path);
    }
    catch(e) {
      window.alert('Save As error:\n'+
          (e.number & 0xFFFF)+' '+e.message);
    }
  }
  else if (('GeckoActiveXObject' in window) &&
      (netscape) && (netscape.security)) {
    var txt = doc.getElementsByTagName('PRE')[0].
      firstChild.nodeValue;
    window.location = saveAs.GeckoPrompt + escape(txt);
  }
  else {
    window.alert('Required feature is missing');
  }
}

saveAs.GeckoPrompt = 'data:TEXT FILE Please add .txt extension,';

function init() {
  window.frames['UIN'].document.designMode = 'on';
}

window.onload = init;
</script>
</head>

<body>
<form action="" onsubmit="return false;">
<fieldset>
  <legend>Save As</legend>
  <p><iframe name="UIN" src="demo_order.xml" style="width:30em; height:3em;"></iframe></p>
  <p><button type="button" accesskey="s" 
    onclick="saveAs(window.frames['UIN'].document, 'C:\\foobar.txt')">
    <u>S</u>ave</button>
  </p>
</fieldset>
</form>

<noscript>
<p style="color:red">If you see this text then it means
that the current browser settings do not allow script
execution for this page.</p>
</noscript>

</body>
</html>
